import { addUserMoney,getUserList } from '@/api/moneyApi'
export default {
    state: {
        moneyList: []
    },
    mutations: {
        add(state, money) {
            state.moneyList.userData.push(money)
        },
        pageData(state,pagedata){
            state.moneyList = pagedata
        },
        updateStatue(state,num){
            console.log(state.moneyList.userData);
            const res = state.moneyList.userData.find(item => item.num === num )
            res.status = "已报销"
        }
    },
    actions: {
        //添加用户报销数据
        async addMoneyAction({ commit }, ruleForm) {
            let ret = await addUserMoney(ruleForm)
            commit('add', ret.data)
            return ret.code === 0 ? true : false
        },
        // 获取用户报销数据
        async getUserList({ commit }, page = 1) {
            let ret = await getUserList(page)
            commit('pageData',ret.data)
        },
    }
}